#define _CRT_SECURE_NO_WARNINGS 1
int* masterMind(char* solution, char* guess, int* returnSize) {
    *returnSize = 2;
    int* ret_answer = (int*)calloc(2, sizeof(int));
    int s_count[4] = { 0 };
    int g_count[4] = { 0 };
    for (int i = 0; i < 4;i++)
    {
        if (solution[i] == guess[i])
        {
            ret_answer[0]++;
        }
    }
    for (int i = 0; i < 4;i++)
    {
        switch (solution[i])
        {
        case 'R':
            s_count[0]++;
            break;

        case 'Y':
            s_count[1]++;
            break;

        case 'G':
            s_count[2]++;
            break;

        case 'B':
            s_count[3]++;
            break;

        }
        switch (guess[i])
        {
        case 'R':
            g_count[0]++;
            break;

        case 'Y':
            g_count[1]++;
            break;

        case 'G':
            g_count[2]++;
            break;

        case 'B':
            g_count[3]++;
            break;

        }
    }
    for (int i = 0; i < 4;i++)
    {
        if (s_count[i] != 0 && g_count[i] != 0 && s_count[i] <= g_count[i])
        {
            ret_answer[1] += s_count[i];
        }
        else if (s_count[i] != 0 && g_count[i] != 0)
        {
            ret_answer[1] += g_count[i];
        }
    }
    ret_answer[1] -= ret_answer[0];
    return ret_answer;
}